﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ITSupportPlatform
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DAL.FounderOAResourceGroupEntities context = new DAL.FounderOAResourceGroupEntities();
            string domainAndName = Page.User.Identity.Name;//读取域登录用户名，格式为Domainname\username （域名名称\用户名称） 
            DAL.Org_Users info = context.Org_Users.Where(x => x.LoginID.ToLower() == domainAndName.ToLower()).SingleOrDefault();

            //string[] infoes = domainAndName.Split(new char[1] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
            //string userDomainName = "";//Domain 用户登录WINDOWS系统的域名
            //string userName = "";//Username 用户登录WINDOWS系统的用户名
            //if (infoes.Length > 1)
            //{
            //    userDomainName = infoes[0];//Domain
            //    userName = infoes[1];//Username
            //}
            if (info.DeptID.Value.ToString().ToUpper()==System.Configuration.ConfigurationManager.AppSettings["InfomationDept"])
            {
                ShowToInfomation.Visible = true;
            }
            else
            {
                ShowToInfomation.Visible = false;
            }
            userInfo.InnerText = string.Format("{0}", info != null ? "欢迎您，" + info.Name : "未登录");
        }
    }
}
